home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MSG Graphic Effects 1.0 Source / Random wipe.c < prev    next >
Text File  |  1993-08-21  |  2KB  |  66 lines

  1. /*******************************************************************************
  2.  * Copywrite © 1992-1993 David S. Blumenthal                                   *
  3.  *                                                                             *
  4.  * This file is provided as is, and may be freely distributed unaltered.  This *
  5.  * message must accompany any copy of this file.  This file may be used or     *
  6.  * modified for use for a non-commercial product provided that appropriate     *
  7.  * credit is given to the author named above.                                  *
  8.  * Commercial use of this source code is prohibited.                           *
  9.  ******************************************************************************/
  10.  
  11. #include "msg misc.h"
  12. #include "msg timing.h"
  13.  
  14. #define        SUB_HOR        20
  15. #define        SUB_VER        20
  16. #define        AREA        (SUB_HOR * SUB_VER)
  17. #define CorrectTime 1
  18.  
  19. void RandomWipe(GrafPtr);
  20.  
  21. /* Basically, we divide the window into a bunch of blocks, and copy
  22. each to the screen in random order. */
  23. void RandomWipe(GrafPtr myGrafPtr)
  24. {
  25.     int        order[AREA];
  26.     int        i;
  27.     long    randtemp;
  28.     int        ordertemp;
  29.     Rect    subBox;
  30.     Rect    dest;
  31.     Boolean    everyOther;
  32.     
  33.     everyOther=FALSE;
  34.     for(i = 0; i < AREA; i++)
  35.         order[i] = i;
  36.     
  37.     for(i = (AREA - 1); i >= 0; i--) {
  38.         randtemp = ((((long)Random()) +32767) * (i + 1)) / 65535;
  39.         
  40.         ordertemp = order[randtemp];
  41.         order[randtemp] = order[i];
  42.         order[i] = ordertemp;
  43.     }
  44.     
  45.     for(i = 0; i < AREA; i++) {
  46.         StartTiming();
  47.         subBox.top = (((order[i] / SUB_VER) *
  48.                         ((myGrafPtr->portRect).bottom - (myGrafPtr->portRect).top))
  49.                         / SUB_VER) + (myGrafPtr->portRect).top;
  50.         subBox.left = (((order[i] % SUB_HOR) *
  51.                         ((myGrafPtr->portRect).right - (myGrafPtr->portRect).left))
  52.                         / SUB_HOR) + (myGrafPtr->portRect).left;
  53.         subBox.bottom = ((((order[i] / SUB_VER) + 1) *
  54.                         ((myGrafPtr->portRect).bottom - (myGrafPtr->portRect).top))
  55.                         / SUB_VER) + (myGrafPtr->portRect).top;
  56.         subBox.right = ((((order[i] % SUB_HOR) + 1) *
  57.                         ((myGrafPtr->portRect).right - (myGrafPtr->portRect).left))
  58.                         / SUB_HOR) + (myGrafPtr->portRect).left;
  59.         
  60.         CopyBits(&(myGrafPtr->portBits), &(gMainWindow->portBits),
  61.             &subBox, &subBox, 0, 0L);
  62.         if (everyOther)
  63.             TimeCorrection(CorrectTime);
  64.         everyOther=!everyOther;
  65.     }
  66. }